package com.objectproject.main.service.subsystem.loader;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.objectproject.main.dao.MyGroupDAOImpl;
import com.objectproject.main.model.MyGroup;

@Service
public class GroupDetailLoader {
	
	@Autowired
	MyGroupDAOImpl myGroupDAOImpl;
	
	
	public void loadGroupDetails(ArrayList<MyGroup> myProperties, int localeId){
		for(MyGroup myGroup:myProperties){
			MyGroup myGroupDetail = myGroupDAOImpl.selectMyGroupDetail(myGroup, localeId);
			loadGroupDetailEasy(myGroup, myGroupDetail);
		}
	}
	
	public void loadGroupDetail(MyGroup myGroup,  int localeId){
		MyGroup myGroupDetail = myGroupDAOImpl.selectMyGroupDetail(myGroup, localeId);
		loadGroupDetailEasy(myGroup, myGroupDetail);
			
	}
	
	//helper
	private void loadGroupDetailEasy(MyGroup myGroup, MyGroup myGroupDetail){
		myGroup.setPrivate(myGroupDetail.isPrivate());
		myGroup.setSystem(myGroupDetail.isSystem());
		myGroup.setOwner(myGroupDetail.getOwner());
	}
}
